home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0050_256 VGA Colors.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-31  |  3KB  |  103 lines

  1. ==============================================================================
  2.  BBS: «« The Information and Technology Exchan
  3.   To: DOUGLAS BAKER                Date: 11-11─91 (20:18)
  4. From: WILBERT VAN.LEIJEN         Number: 2147   [101] PASCAL
  5. Subj: 256 TEXT COLORS?           Status: Public
  6. ------------------------------------------------------------------------------
  7. Hi Doug,
  8.  
  9.  > I was wondering if anyone knows if 256 text colors can be accessed
  10.  > with a VGA adaptor. I figured that since such programs as VGADimmer
  11.  > exist, (to change the brightness) I should be able to change the
  12.  > intensity ofd each color to simulate the 256 colors. Any help and TP
  13.  > 5.5 or 6.0 routines would be appreciated.
  14.  
  15. You can have no more than 16 colours in text mode.  These colours can be
  16. selected on the VGA from 255 registers and changed at will.  Each register can
  17. also be programmed to hold a specific Red, Blue and Green value ranging from
  18. 0..63, giving 64*64*64 = 262,144 unique colours.
  19. The registers are referred to as the 'DAC registers'.
  20.  
  21. Program ShowDoug;
  22.  
  23. {$X+ }
  24.  
  25. uses Crt;
  26.  
  27. Const
  28.   MinIntensity = 0;
  29.   MaxIntensity = 63;
  30.  
  31. Type
  32.   ColourRange  = MinIntensity..MaxIntensity;
  33.   RGBType      = Record
  34.                    r, g, b   : ColourRange;
  35.                  end;
  36.  
  37. { Store colour information to DAC register }
  38.  
  39. Procedure SetRegister(register : Byte; colour : ColourRange); Assembler;
  40.  
  41. ASM
  42.         MOV     BH, colour
  43.         MOV     BL, register
  44.         MOV     AX, 1000h
  45.         INT     10h
  46. end;  { SetRegister }
  47.  
  48. { Store the Red, Green and Blue intensity into a DAC register }
  49.  
  50. Procedure SetRGBValue(register : Byte; RGB : RGBType); Assembler;
  51.  
  52. ASM
  53.         PUSH    DS
  54.         LDS     SI, RGB
  55.         XOR     BX, BX
  56.         MOV     BL, register
  57.         LODSB
  58.         MOV     DH, AL
  59.         LODSW
  60.         XCHG    CX, AX
  61.         XCHG    CH, CL
  62.         MOV     AX, 1010h
  63.         INT     10h
  64.         POP     DS
  65. end;  { SetRGBValue }
  66.  
  67. Var
  68.   i, j, t : Integer;
  69.   RGB : RGBType;
  70.  
  71. Begin
  72.   ClrScr;
  73.   Randomize;
  74.   TextBackground(black);
  75.   For i := 1 to 25 Do
  76.     Begin
  77.       t := 0;
  78.       For j := 1 to 80 Do
  79.         Begin
  80.           TextColor(t);
  81.           If j mod 5 = 0 Then
  82.             Inc(t);
  83.           If not ((j = 80) and (i = 25)) Then
  84.             Write(#219);
  85.       end;
  86.     end;
  87.   Repeat                          { fiddle with the registers }
  88.     SetRegister(Random(16), Random(64));
  89.     Delay(200);
  90.   Until KeyPressed;
  91.   ReadKey;
  92.   Repeat                           { fiddle with the R, G, B values }
  93.     RGB.r := Random(255);
  94.     RGB.g := Random(255);
  95.     RGB.b := Random(255);
  96.     SetRGBValue(Random(64), RGB);
  97.   Until KeyPressed;
  98. end.
  99.  
  100.  
  101. --- Dutchie V2.91d
  102.  * Origin: Point Wilbert | 'I think, therefore I ASM'. (2:500/12.10956)
  103.